<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传头像</title>
    <link rel="stylesheet" href="./css/upload.css">
</head>
<body>
    <div id="content">
        <img id="picture">
        <h3 id="name"></h3>
        <form action="upload" method="post" enctype="multipart/form-data">
            <input id="file" type="file" name="myImage">
            <input id="submit" type="submit" value="上传头像">
        </form>
    </div>

    <script src="jquery.js"></script>
    <script src="js/common.js"></script>

    <script>
        let picture = document.querySelector("#picture");
        let name = document.querySelector("#name");
        $.ajax({
            type: 'get',
            url: 'upload',
            dataType: 'json',
            success: function (body) {
                name.innerHTML = 'hello, ' + body.username;
                picture.src = "./image/" + body.photo + ".png";
            }
        })
    </script>
</body>
</html>